package com.zhong.learning.auto_paper.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhong.learning.auto_paper.po.QuestionPO;
import com.zhong.learning.auto_paper.po.QuestionTypePO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface QuestionPOMapper extends BaseMapper<QuestionPO> {

    @Select("select q.*, qn.answer, qn.difficulty, qn.knowledge " +
            "from t_question q, t_question_nature qn " +
            "where q.id=qn.id and q.type=#{type} and qn.difficulty is not null")
    List<QuestionPO> getQuestionPOByType(String type);

    @Select("select count(type) count, type " +
            "from t_question "+
            "group by type")
    List<QuestionTypePO> getQuestionTypes();

}
